package com.jinlia.show.modules.wxapp.controller;

import com.jinlia.show.common.core.utils.UserInfoUtils;
import com.jinlia.show.modules.base.model.po.GoodsPO;
import com.jinlia.show.modules.base.wxapp.service.FavouriteGoodsMapperService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequiredArgsConstructor
@RequestMapping("/favourite/goods")
public class FavouriteGoodsController {
      @Autowired
    private FavouriteGoodsMapperService favouriteGoodsMapperService;

    @GetMapping(value = "/switch/{goodsId}")
    private ResponseEntity<Boolean> addSwitch(@PathVariable("goodsId") Long goodsId) {
        return ResponseEntity.ok(favouriteGoodsMapperService.addSwitch(UserInfoUtils.getUserId(),goodsId));
    }

    @GetMapping(value = "/{goodsId}")
    private ResponseEntity<Boolean> beLove(@PathVariable("goodsId") Long goodsId) {
        return ResponseEntity.ok(favouriteGoodsMapperService.isLove(UserInfoUtils.getUserId(),goodsId));
    }
    @GetMapping(value = "/get")
    private ResponseEntity<List<GoodsPO>> getLove() {
        return ResponseEntity.ok(favouriteGoodsMapperService.getLove(UserInfoUtils.getUserId()));
    }
}
